var ibMarketPluginBankStarters = {
	init: function()
	{
		Debug.write("Initializing ibm.plugin.bank.starter.js");
		
		document.observe("dom:loaded", function(){
			ibMarketPluginBankStarters.loadStarter();
			$('starterID').observe('change',ibMarketPluginBankStarters.loadStarter);
			$('starterID').observe('keyup',ibMarketPluginBankStarters.loadStarter);
			$('starterID').observe('keydown',ibMarketPluginBankStarters.loadStarter);
		});
	},
	
	loadStarter: function()
	{
		var starterID = $('starterID').value;
		new Ajax.Request( ipb.vars['base_url'] + "app=ibmarket&module=ajax&plugin=bank&action=starter&starter_id=" + starterID + "&secure_key=" + ipb.vars['secure_hash'], 
							{
								method: 'get',
								evalJSON: 'force',
								onSuccess: function(t)
								{
									if( Object.isUndefined( t.responseJSON ) )
									{
										Debug.error("Invalid server response");
										return false;
									}
									
									if( t.responseJSON['error'] )
									{
										Debug.error( t.responseJSON['error'] );
										return false;
									}
									
									accountStarter = t.responseJSON;
									$('description').update(accountStarter['description']);
									$('creationFee').update(accountStarter['create_fee']);
									$('interestRate').update(accountStarter['interest_time']);
									$('interestTime').update(accountStarter['interest_rate']);
									$('depositFee').update(accountStarter['deposit_fee']);
									$('withdrawFee').update(accountStarter['withdraw_fee']);
									$('removalFee').update(accountStarter['remove_fee']);
									
									return true;
								}
							});
	}
}

ibMarketPluginBankStarters.init();